﻿Imports System.Windows.Forms

Public Class Exploreversion

    Public Event selected(ByVal selected_flag As String)

    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Public Sub New(ByVal prjname As String)
        ' This call is required by the designer.
        InitializeComponent()
        ' Add any initialization after the InitializeComponent() call.
        Flag_view1.RootPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) & "\Omnisource\flags\" & prjname
    End Sub

    Private Sub Flag_view1_selected(ByVal v As String)
        Dim msgrslt As Microsoft.VisualBasic.MsgBoxResult
        msgrslt = MsgBox("Are you sure you want to restore your project..?")
        If msgrslt = MsgBoxResult.Ok Then
            restore(v)
            Me.Close()
        End If
    End Sub

    Private Sub restore(ByVal flag As String)
        FileIO.FileSystem.DeleteDirectory(main.ProjectPath, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.DeletePermanently, FileIO.UICancelOption.DoNothing)
        FileIO.FileSystem.CreateDirectory(main.ProjectPath)
        FileIO.FileSystem.CopyDirectory(flag, main.ProjectPath)
        MsgBox("Reset done! :)")
    End Sub

End Class
